import gradio as gr


def translator(model_type, model, target_language, api_key, filepath):
    return f"""
    filepath: {filepath}\n
    mode_type: {model_type}\n
    model: {model}\n
    target_language: {target_language}\n
    api_key: {api_key}\n
    """


if __name__ == "__main__":
    translator_gui = gr.Interface(
        fn=translator,
        title='Mini AI Translator',
        inputs=[
            gr.Dropdown(
                ['OpenAIModel', 'ChatGLMModel'], label='model_type',
                info='The type of translation model to use. Choose between "OpenAIModel" and "ChatGLMModel".'
            ),
            gr.Dropdown(
                ['gpt-3.5-turbo', 'glm-4'], label='model',
                info='The specific model to use for translation. For example, "gpt-3.5-turbo" for OpenAIModel or "glm-4" for ChatGLMModel.'
            ),
            gr.Dropdown(
                ['Chinese', 'Japanese'], label='target_language', info='Choose the target language for translation.'
            ),
            gr.Textbox(label="api_key", info='API key corresponding to the selected model_type.'),
            gr.File(label='Upload the PDF file that needs to be translated'),
        ],
        outputs=["text"],
        examples=[
            ['OpenAIModel', 'gpt-3.5-turbo', 'Chinese', 'xxx', None],
            ['ChatGLMModel', 'glm-4', 'Japanese', 'xxx', None],
        ]
    )

    translator_gui.launch(share=True)
